import java.util.*;

/**
 * Created by forcht on 2018/4/26.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        Set<Integer> set=new TreeSet<>();
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            set.add(a[i]);
        }
        for (int i = 0; i < m; i++) {
            b[i] = scanner.nextInt();
            set.add(b[i]);
        }
        Iterator<Integer> iterator = set.iterator();
        boolean flag=false;
        while (iterator.hasNext()){
            if (flag) System.out.print(" ");
            flag=true;
            System.out.print(iterator.next());
        }
    }
}
